package com.shanzmoo.merchant.manage.api.web.product;

import com.shanzmoo.base.bean.PageRespBase;
import com.shanzmoo.base.bean.SHttpResponse;
import com.shanzmoo.db.module.product.domain.dto.AttributeSaveDto;
import com.shanzmoo.db.module.product.domain.dto.AttributeUpdateDto;
import com.shanzmoo.db.module.product.domain.query.AttributeQueryVO;
import com.shanzmoo.db.module.product.domain.vo.AttributeVO;
import com.shanzmoo.db.module.product.entity.ProductAttributeEntity;
import com.shanzmoo.merchant.manage.api.manager.product.ProductAttributeManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 商品规格manager
 * @author xueqz
 */
@Api(tags = "商品管理系统-规格")
@RestController
@RequestMapping("/api/product/attribute")
public class ProductAttributeController {

    @Autowired
    private ProductAttributeManager ProductAttributeManager;

    @ApiOperation(value = "商品规格list")
    @PostMapping("/attributeList")
    public SHttpResponse<PageRespBase<AttributeVO>> attributeList(@RequestBody AttributeQueryVO AttributeQueryVO) {

        return ProductAttributeManager.attributeList(AttributeQueryVO);
    }

    @ApiOperation(value = "添加商品规格")
    @PostMapping("/addAttribute")
    public SHttpResponse<Boolean> addAttribute(@RequestBody AttributeSaveDto attributeSaveDto) {

        return ProductAttributeManager.addAttribute(attributeSaveDto);
    }

    @ApiOperation(value = "删除商品规格")
    @GetMapping("/delAttributeById")
    public SHttpResponse<Boolean> delAttributeById(@RequestParam(value = "attributeId") Integer attributeId) {

        return ProductAttributeManager.delAttributeById(attributeId);
    }

    @ApiOperation(value = "更新商品规格")
    @PostMapping("/updateAttribute")
    public SHttpResponse<Boolean> updateAttribute(@RequestBody AttributeUpdateDto attributeUpdateDto) {

        return ProductAttributeManager.updateAttribute(attributeUpdateDto);
    }



}
